/*
 * This file is part of Catfish.
 * Copyright (C) 2010 Namazu Studios LLC
 * 
 * Catfish is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of 
 * the License, or (at your option) any later version.
 * 
 * Catfish is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with Catfish.  If not, please visit:
 *  
 * http://www.gnu.org/licenses/
 *  
 */
package com.namazustudios.catfish;

import java.util.IdentityHashMap;

import com.google.appengine.api.datastore.Entity;

/**
 * Interface to a to an object responsible to converting Objects to Entities.
 * When marshalling, it may produce several child entities. The resulting graph
 * of objects is returned as a Mapping of Objects to Entities. The resultant set
 * will contain at least one object which is the object passed in to the
 * marshall method.
 * 
 * @author patrick
 * 
 */
public interface Marshaller {

    /**
     * Converts the given object graph to a set of Entities. This maps the
     * Objects to the resultant entities. One Object may produce several
     * Entities. All Entities in the returned map will be part of the same
     * entity group and can be written from within the context of a Transaction.
     * 
     * @param object
     *            the object to marshall
     * @return the resulting marshalled Map of values, all keyed to belong to
     *         the same Entity group
     */
    public abstract IdentityHashMap<Object, Entity> marshall(Object object);

}